/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sqlserver;

import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author PHAMDANH
 */
public class IconCellRenderer extends DefaultTableCellRenderer 
    {
        private ImageIcon primaryKeyIcon = new ImageIcon(getClass().getResource("/images/primary_key.png"));
        public IconCellRenderer() 
        {
        }

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, 
                                                        boolean isSelected, boolean hasFocus, int row, int column) 
        {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if(value!=null&&(Boolean)value)
            {
                setIcon(primaryKeyIcon);
            }
            else
                setIcon(null);
            this.setText("");            
            return this;
        }
}
